﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace ReceiptTracker
{
    public partial class FormAdvanced : Form
    {
        private SQLiteDB db;
        private DataTable dt = new DataTable();
        public FormAdvanced(SQLiteDB db)
        {
            InitializeComponent();
            this.db = db;
            dataGridView.DataSource = dt;
        }

        private void buttonQuery_Click(object sender, EventArgs e)
        {
            if (textBoxQuery.Text != "")
            {

                if (textBoxQuery.Text.Substring(0,6) == "SELECT")
                {
                    db.SQLQuery(textBoxQuery.Text);
                    dt.Clear();
                    dt.Merge(db.QueryResult);
                }
                else
                {
                    db.SQLCommand(textBoxQuery.Text);                    
                }
            }
        }
    }
}
